<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('下载新闻')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-contentList-add">
        <!--<div class="form-group">
            <label class="col-sm-3 control-label is-required">独立法人机构：</label>
            <div class="col-sm-8">
                <select name="deptId" id="deptId" class="form-control m-b" onchange="deptChange()"
                        th:with="type=${@dept.selectDeptListByType('2')}"
                        required>
                    <option value="">请选择</option>
                    <option th:each="dept : ${type}" th:text="${dept.deptName}" th:value="${dept.deptId}"></option>
                </select>
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">频道：</label>
            <div class="col-sm-8" id="channel">
                <!--<select name="channelIds" id="channelIds" class="form-control m-b" onchange="channelIdChange()">-->
                    <!--<option value="">请选择</option>-->
                <!--</select>-->
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">页数：</label>
            <div class="col-sm-8">
                <input name="page" class="form-control" type="number" maxlength="32" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">每页条数：</label>
            <div class="col-sm-8">
                <input name="maxResult" class="form-control" type="number" maxlength="32" required>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "config/contentList"
    $("#form-contentList-add").validate({
        focusCleanup: true
    });

    $(function () {
        deptChange();
    })
    function submitHandler() {
        if ($.validate.form()) {
            var channelId = $("#channelId").val();
            if (channelId == "" || channelId == "undefine") {
                $.modal.alertWarning("请选择频道！");
                return;
            }
            $.operate.save(prefix + "/downLoad", $('#form-contentList-add').serialize());
        }
    }

    function deptChange() {
        $.ajax({
            type: "post",
            url: ctx + "config/channelList/channelList",
            data: {},
            success: function (result) {
                if (result.code == web_status.SUCCESS) {
                    var channelIdStr = '';
                    var channelData = result.data;
                    for (var i = 0; i < channelData.length; i++) {
                        //channelIdStr += '<option value="' + channelData[i].channelId + '">' + channelData[i].name + '</option>';
                        channelIdStr +=
                            '<lable  class="check-box">' +
                            '<input name="channelId" id="channelId' + i + '" type="checkbox"   value="' + channelData[i].channelId + '" required/>&nbsp;' + channelData[i].name
                            + '</div>';
                    }
                    $('#channel').html(channelIdStr);

                }
            }
        });
    }

    // function channelIdChange() {
    //     $('#channelId').val($('#channelIds').val());
    // }
</script>
</body>
</html>